# 第一题

lst = [1, 4, 9, 16, 2, 5, 10, 15]
new_lst = []
for i in range(len(lst) - 1):
    new_lst.append(lst[i] + lst[i + 1])
# new_lst = [lst[i] + lst[i + 1] for i in range(len(lst) - 1)]
print(new_lst)

# 第二题

import random

num_lst = [random.randint(1, 20) for _ in range(20)]
print(num_lst)
num_count = {}

for num in num_lst:
    if num not in num_count:
        num_count[num] = 0
    # num_count.setdefault(num, 0) 和上面if判断等价
    num_count[num] += 1
print(num_count.items())

d_temp = {}
for k, v in num_count.items():
    d_temp.setdefault(v, [])
    d_temp[v].append(k)
res1 = [(k, v) for v in sorted(d_temp, reverse=True) for k in d_temp[v]]
print(res1[:3])

res2 = sorted(num_count.items(), key=lambda item: item[1], reverse=True) # 定义排序规则，用到匿名函数
print(res2[:3])

# 第三题

import random

s = 'abcdefghijklmnopqrstuvwxyz'

res1 = []
for i in range(1, 101):
    p_id = '{:0>6}.{}'.format(i, "".join([random.choice(s) for _ in range(10)]))
    res1.append(p_id)
print(res1)

res2 = [f'{i:0>6}.{"".join([random.choice(s) for _ in range(10)])}' for i in range(1, 101)]
print(res2)

res3 = [f'{i:0>6}.{"".join(random.choices(s, k=10))}' for i in range(1, 101)]
print(res3)

# 第四题


# 同第二题思路一样，不再做重复解答
